import axios from '@/utils/request'

//查询角色
export const getRoleListDataAsync = (params) => {
  const { currPage, pageSize, key } = params
  return axios.get(`/lanlu/role/list?currPage=${currPage}&pageSize=${pageSize}&key=${key}`)
}

//添加/更新角色 
/**
 * 添加 roleName,roleDesc,orderRank
 * 更新 id,roleName,roleDesc,orderRank
 */
export const addOrUpdateRoleAsync = (params) => {
  return axios.post('/lanlu/role/saveOrUpdate', params)
}
//获取角色信息
export const getRoleInfoAsync = (params) => {
  const { id } = params
  return axios.get(`/lanlu/role/goUpdatePage?id=${id}`)
}


//删除角色信息
/**
 * code 200 成功
 * 515  删除失败
 */
export const deleteRoleInfoAsync = (params) => {
  const { id } = params
  return axios.delete(`/lanlu/role/deleteRole/${id}`)
}


//分配菜单 回显信息
export const getRoleMenuListAysnc = (params) => {
  const { id } = params
  return axios.get(`/lanlu/role/allocateMenu?id=${id}`)
}

//分配菜单 更新信息
export const updateRoleMenuListAsync = (params) => {
  return axios.post('/lanlu/role/saveRoleAndMenu', params)
}

